
package com.javaleague.persistencia.mysqlLocal;

import java.sql.Connection;
import java.sql.SQLException;
import javax.naming.NamingException;
import javax.sql.DataSource;

/**
 * @author TaixMiguel
 */

public class Conexion {    
    public static Connection getConexion() {
        DataSource ds = null;
        Connection conexion = null;
        
        try {
            ds = (DataSource) new javax.naming.InitialContext().lookup("java:comp/env/jdbc/JavaLeague");
            conexion = ds.getConnection();
        } catch (NamingException ex) {            
            com.javaleague.informacion.ErrorGeneral.guardarLog(Object.class.getName(), "No se ha podido conectar a la BBDD", ex);
        } catch (SQLException ex) {
            com.javaleague.informacion.ErrorGeneral.guardarLog(Object.class.getName(), "No se ha podido establecer la conexion", ex);
        }
        
        return conexion;
    }
}